/**
 * VUEshop
 * ============================================================================
 * * 版权所有 2015-2027 深圳搜豹网络科技有限公司，并保留所有权利。
 * 网站地址: http://www.vueshop.com.cn
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
 * 不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * $Author: soubao-java 2020-07-22 $
 */<template>
  <div>
    <div class="item-title">
      <div class="subject">
        <h3>投诉管理</h3>
        <h5>商城对商品交易投诉管理及仲裁</h5>
      </div>
      <ul class="tab-base nc-row">
        <router-link :to="{name:'complains'}" :active-class="state==1 ? 'current' : ''">
          <li @click="state=1;currentPage = 1;getPage()">
            <a>
              <span>新投诉</span>
            </a>
          </li>
        </router-link>
        <router-link :to="{name:'complains'}" :active-class="state==2 ? 'current' : ''">
          <li @click="state=2;currentPage = 1;getPage()">
            <a>
              <span>对话中</span>
            </a>
          </li>
        </router-link>
        <router-link :to="{name:'complains'}" :active-class="state==3 ? 'current' : ''">
          <li @click="state=3;currentPage = 1;getPage()">
            <a>
              <span>待仲裁</span>
            </a>
          </li>
        </router-link>
        <router-link :to="{name:'complains'}" :active-class="state==4 ? 'current' : ''">
          <li @click="state=4;currentPage = 1;getPage()">
            <a>
              <span>已完成</span>
            </a>
          </li>
        </router-link>
        <router-link :to="{name:'complain_subject'}">
          <li>
            <a>
              <span>主题设置</span>
            </a>
          </li>
        </router-link>
        <router-link :to="{name:'complain_time'}">
          <li>
            <a>
              <span>时效设置</span>
            </a>
          </li>
        </router-link>
      </ul>
    </div>
    <div
      class="explanation"
      style="color: rgb(85, 85, 85); background-color: rgb(243, 244, 244); width: 98%; height: 100%;"
    >
      <div class="bckopa-tips">
        <div class="title">
          <img src="@/static/images/handd.png" alt />
          <h4 title="提示相关设置操作时应注意的要点">操作提示</h4>
        </div>
        <ul>
          <li>在投诉时效内，买家可对订单进行投诉，投诉主题由管理员在后台统一设置</li>
          <li>投诉时效可在系统设置处进行设置</li>
          <li>点击详细，可查看投诉。被投诉店铺可进行回复进行申诉。申诉成功后，投诉双方进行对话</li>
          <li>会员可确认结束纠纷单，若会员对于卖家的处理不满意可以申请仲裁，最后由后台管理员进行仲裁操作</li>
        </ul>
      </div>
      <span title="收起提示" id="explanationZoom" style="display: block;"></span>
    </div>

    <div class="mDiv">
      <div class="ftitle">
        <h3>商家投诉列表</h3>
        <h5>(共 {{totalCount}} 条记录)</h5>
      </div>
      <a href @click.prevent="refresh()" class="refresh-date">
        <div title="刷新数据" class="pReload">
          <i class="fa fa-refresh"></i>
        </div>
      </a>
      <div class="searchbox">
        <el-input
          class="searchinput"
          v-model="username"
          width="10"
          size="small"
          placeholder="投诉人"
          clearable
        />
        <el-input
          class="searchinput"
          v-model="store_name"
          width="10"
          size="small"
          placeholder="被投商家"
          clearable
        />
        <el-button
          class="searchbtn"
          size="small"
          icon="el-icon-search"
          @click="currentPage = 1;getPage()"
        >搜索</el-button>
      </div>
    </div>
    <div class="tablebox">
      <el-table :data="tableData" style="width: 100%;">
        <el-table-column label="投诉人" prop="user_name" width="180" show-overflow-tooltip></el-table-column>
        <el-table-column label="投诉内容" prop="complain_content" width="180"></el-table-column>
        <el-table-column label="投诉图片" width="100">
          <template scope="scope">
            <img :src="scope.row.complain_pic" width="40" height="30" />
          </template>
        </el-table-column>
        <el-table-column label="投诉时间" prop="complain_time_show" width="180" show-overflow-tooltip></el-table-column>
        <el-table-column label="投诉主题" prop="complain_subject_name" width="100"></el-table-column>
        <el-table-column label="被投商家" prop="store_name" width="140"></el-table-column>
        <el-table-column label="投诉人ID" prop="user_id" width="100"></el-table-column>
        <el-table-column label="商家ID" prop="store_id" width="100"></el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button-group>
              <el-button
                size="small"
                @click="complainDetail(scope.row.order_id, scope.row.complain_id)"
                icon="el-icon-s-order"
              >查看</el-button>
            </el-button-group>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        background
        class="paginationbox"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[5, 10, 15, 20]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="totalCount"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
import { getComplainPage } from "@/utils/api";
export default {
  data() {
    return {
      tableData: [],
      currentPage: this.$route.params.currentPage || 1,
      state: this.$route.params.state || 1,
      totalCount: 0,
      pageSize: 10,
      username: "",
      store_name: ""
    };
  },
  created() {
    this.getPage();
  },
  methods: {
    handleSizeChange(e) {
      this.pageSize = e;
      this.getPage();
    },
    handleCurrentChange(e) {
      this.currentPage = e;
      this.getPage();
    },
    getPage() {
      var that = this;
      getComplainPage({
        username: this.username,
        store_name: this.store_name,
        state: this.state,
        p: this.currentPage,
        size: this.pageSize
      }).then(function(res) {
        that.tableData = res.records;
        that.totalCount = res.total;
      });
    },
    refresh() {
      this.getPage();
      this.$message.success("刷新成功！");
    },
    complainDetail(order_id, complainId) {
      this.$router.push({
        name: "complain_detail",
        params: {
          order_id: order_id,
          complainId: complainId,
          currentPage: this.currentPage
        }
      });
    }
  }
};
</script>

<style scoped>
.searchinput {
  width: auto;
}
</style>
